package org.stars.daostars;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

import org.stars.daostars.core.DaoStars;
import org.stars.daostars.events.DaoEventHandler;
import org.stars.security.UserIdentity;
import org.stars.security.UserIdentityImpl;
import org.stars.util.diagnostic.StackTraceDiagnosticHandler;

public class QueryConfigImpl implements QueryConfig {
	protected boolean	debugMode;
	protected UserIdentity user;
	protected Locale	locale;
	protected Map<String, String> variables;
	protected StackTraceDiagnosticHandler stackTraceDiagnosticHandler;
	protected SQLExceptionTranslator sqlExceptionTranslator;
	protected DaoEventHandler daoEventHandler;

	private static final long serialVersionUID = 7884744890358937762L;
	
	public QueryConfigImpl()
	{
		user=new UserIdentityImpl();
		locale=Locale.ENGLISH;
		variables=new HashMap<String, String>();
		stackTraceDiagnosticHandler=DaoStars.getInstance().getStackTraceDiagnosticHandler();
		sqlExceptionTranslator=DaoStars.getInstance().getSQLExceptionTranslator();
		
		// per default nessun event handler
		daoEventHandler=null;
	}

	@Override
	public void setUser(UserIdentity value) {
		user=value;
	}

	@Override
	public UserIdentity getUser() {
		return user;
	}

	@Override
	public void setLocale(Locale value) {
		locale=value;		
	}

	@Override
	public Locale getLocale() {
		return locale;
	}

	@Override
	public void setVariables(Map<String, String> value) {
		variables=value;		
	}

	@Override
	public Map<String, String> getVariables() {
		return variables;
	}

	@Override
	public void setStackTraceDiagnosticHandler(StackTraceDiagnosticHandler value) {
		stackTraceDiagnosticHandler=value;
	}

	@Override
	public StackTraceDiagnosticHandler getStackTraceDiagnosticHandler() {
		return stackTraceDiagnosticHandler;
	}

	@Override
	public void setDebugMode(boolean value) {
		debugMode=value;
	}

	@Override
	public boolean isDebugMode() {
		return debugMode;
	}

	@Override
	public void setDaoEventHandler(DaoEventHandler value) {
		daoEventHandler=value;
	}

	@Override
	public DaoEventHandler getDaoEventHandler() {
		return daoEventHandler;
	}

}
